package main

import (
	"fmt"
)


func main(){
	var j = 10
	var h = 20
	//one 
	for i:=0; i<10;i++{
		fmt.Println(i)
	}

	//two
	// for {
	// 	fmt.Println("always executing...")
	// }
	
	// three
	for j <h {
		j++
		fmt.Println(j)
	}

	numbers := [5]int{1,2,3,4,5}
	fmt.Println(numbers[0])

	for i,x:=range numbers{
		fmt.Printf("第%d位值为：%d\n",i,x)
	}


	fmt.Println(max(10,8))
	fmt.Println(multiResult("hello","world"))

	//引用传递改变地址值
	var m = 5
	var n = 10
	fmt.Printf("交换地址前m的值:%d\n",m)
	fmt.Printf("交换地址后n的值:%d\n",n)
	refrence(&m,&n)
	fmt.Printf("m的值:%d\n",m)
	fmt.Printf("n的值:%d\n",n)
}

/*函数定义*/
func max( x, y int) int {
	var result int
	if(x>y){
		result = x
	}else{
		result = y
	}

	return result
}
/*返回多个值*/
func multiResult(x,y string)(string,string){
	return y,x
}

func refrence( a ,b *int){
	var temp int
	temp = *a
	*a = *b
	*b = temp
}